UICommonNotice = {}
HelperFunc.SetUIEnv(UICommonNotice)
local this = UICommonNotice

this.LuaBehaviour = nil;
this.transform = nil;
this.gameObject = nil;
this.table_Pop = {};
this.pop1 = nil;
this.pop2 = nil;
this.pop3 = nil;
this.txtTitle = nil;
this.btnOK = nil;

this.hasInit = false;
this.title = nil;
this.content = {};
this.cbFun = nil;
this.list = nil;

function UICommonNotice.Init(msg1, msg2, callback)
    title = msg1;
    content = msg2;
    cbFun = callback;

    local name, packageName = getUIName(PanelNames.UICommonNotice);
	panelMgr:ShowUI(name, packageName, this.OnCreate,Config.useLocalUI);
end

function UICommonNotice.OnCreate(obj)
	if not hasInit then
		hasInit = true;
		-- gameObject = obj;
		-- transform = obj.transform;
		-- LuaBehaviour = transform:GetComponent('LuaBehaviour');

        -- pop1 = obj:GetChild("textList/Pop1"):GetComponent("TextMeshProUGUI");
        -- pop2 = obj:GetChild("textList/Pop2"):GetComponent("TextMeshProUGUI");
        -- pop3 = obj:GetChild("textList/Pop3"):GetComponent("TextMeshProUGUI");
        -- table_Pop = {};
        -- table.insert(table_Pop,pop1);
        -- table.insert(table_Pop,pop2);
        -- table.insert(table_Pop,pop3);
        txtTitle = obj:GetChild("TitleLb")-- :GetComponent("TextMeshProUGUI");
        list = obj:GetChild("List");
        btnOK = obj:GetChild("BG");
        this.addEvent();
	end
    -- panelMgr.ShowFadeEff(transform);
    -- transform:SetAsLastSibling(); 
    
    txtTitle.text = title;
    list:RemoveChildrenToPool()
    for i = 1, #content do
        local item = list:AddItemFromPool()
        -- table_Pop[i].gameObject:SetActive(true);
        item:GetChild("Name").text = content[i]["name"];
        item:GetChild("Text").text = content[i]["info"];
    end
    --txtContent.text = content;
    -- EventTriggerListener.Get(btnOK.gameObject).onPointerClick = EventTriggerListener.Get(btnOK.gameObject).onPointerClick + this.onClickConfirm ;
end

function UICommonNotice.addEvent()
    btnOK.onClick:Add(this.onClickConfirm);
end

function UICommonNotice.removeEvent()
    btnOK.onClick:Remove(this.onClickConfirm);
end

function UICommonNotice.OnDestroy()
    this.removeEvent();
end

function UICommonNotice.onClickConfirm()
    if cbFun ~= nil then
        cbFun();
    end
    closeUI(PanelNames.UICommonNotice);
end

return UICommonNotice;